package cn.com.joycode.nimble.core.message;

import cn.com.joycode.nimble.core.error.NbError;
import cn.com.joycode.nimble.core.error.NbErrorObject;
import cn.com.joycode.nimble.core.lang.AbstractNbObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Max Woods
 * @since 1.0
 */

@Data
@EqualsAndHashCode(callSuper = false)
public class NbMsgError extends AbstractNbObject implements NbError {

    private String code;

    private String msg;

    private String subCode;

    private String subMsg;

    @JsonIgnore
    public NbError getMsgError() {
        return new NbErrorObject(code, msg);
    }

    @JsonIgnore
    public NbError getSubError() {
        return new NbErrorObject(subCode, subMsg);
    }

    public void setError(NbError nbError) {
        this.code = nbError.getCode();
        this.msg = nbError.getMsg();
    }

    public void setError(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public void setSubError(NbError nbError) {
        this.subCode = nbError.getCode();
        this.subMsg = nbError.getMsg();
    }

    public void setSubError(String code, String msg) {
        this.subCode = code;
        this.subMsg = msg;
    }
}


